//
//  NYDaoLanCell.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2020/12/30.
//  Copyright © 2020 叁拾叁. All rights reserved.
//

import UIKit

class DYDaoLanCell: SYBaseCell {

    let nameLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x1E1E1E)
        v.font = 14.autoFontSize()
        return v
    }()
    
    let tagLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x00C793)
        v.font = 11.autoFontSize()
        v.backgroundColor = UIColor(hex: 0xE0F6F0)
        return v
    }()
    
    let priceLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0xF55035)
        v.font = 15.autoFontSize()
        return v
    }()
    
    let priceDetaLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0xAFAFAF)
        v.font = 10.autoFontSize()
        return v
    }()
    
    let locationLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 10.autoFontSize()
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        v.layer.cornerRadius = 3
        v.layer.masksToBounds = true
        return v
    }()
    
    let locationPic: UIImageView = {
        let v: UIImageView = UIImageView()
        v.image = UIImage(named: "location")
        return v
    }()

    public func configureView(_ model: DYScenicSpotVOListModel) {
        nameLb.text = model.name
        tagLb.text = "  \(model.labelStr ?? "")  "
        locationLb.text = model.address
        
        if let l = model.rates, Int(l) != 0 {
            priceLb.attributedText = self.setPriceLb(l)
            priceDetaLb.text = "起"
        } else {
            priceLb.text = ""
            priceDetaLb.text = "免费景点"
        }
        pic.sy_setWithUrl(model.imgUrl)
    }
    
    public func configureListView(_ model: DYListModel) {
        nameLb.text = model.name
        tagLb.text = "  \(model.labelStr ?? "")  "
        locationLb.text = model.address
        
        if let l = model.rates, Int(l) != 0 {
            priceLb.attributedText = self.setPriceLb(l)
            priceDetaLb.text = "起"
        } else {
            priceLb.text = ""
            priceDetaLb.text = "免费景点"
        }
        pic.sy_setWithUrl(model.imgUrl)
    }
    
    public func configureMSListView(_ model: DYMSListModel) {
        nameLb.text = model.name
        tagLb.text = "  \(model.nameType ?? "")  "
        locationLb.text = model.address
        
        if model.cost != 0 {
            priceLb.attributedText = self.setPriceLb("\(model.cost)")
            priceDetaLb.text = "人均"
        } else {
            priceLb.text = ""
            priceDetaLb.text = "0"
        }
        let imgUrls = model.imgUrl?.components(separatedBy: ",")
        pic.sy_setWithUrl(imgUrls?.first)
    }
    
    public func configureZSListView(_ model: DYZSListModel) {
        nameLb.text = model.name
        tagLb.text = "  \(model.label ?? "")  "
        locationLb.text = model.address
        
        if model.rates != 0 {
            priceLb.attributedText = self.setPriceLb("\(model.rates)")
            priceDetaLb.text = "起"
        } else {
            priceLb.text = ""
            priceDetaLb.text = "0"
        }
        pic.sy_setWithUrl(model.imgUrl)
    }
    
    override func initViews() {
        
        addSubview(nameLb)
        addSubview(tagLb)
        addSubview(priceLb)
        addSubview(priceDetaLb)
        addSubview(locationLb)
        addSubview(pic)
        addSubview(locationPic)
        addSubview(lineView)
        nameLb.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(12.0.autoWidth())
            make.left.equalTo(pic.snp.right).offset(autoWidth(11.5))
            make.right.equalToSuperview().offset(autoWidth(-15.0))
            make.height.equalTo(14.0.autoWidth())
        }
        tagLb.snp.makeConstraints { (make) in
            make.top.equalTo(nameLb.snp.bottom).offset(autoWidth(12.5))
            make.left.equalTo(nameLb.snp.left)
            make.height.equalTo(15.0.autoWidth())
        }
        priceLb.snp.makeConstraints { (make) in
            make.bottom.equalTo(priceDetaLb.snp.bottom)
            make.height.equalTo(12.0.autoWidth())
            make.right.equalTo(priceDetaLb.snp.left)
        }
        priceDetaLb.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(44.0.autoWidth())
            make.right.equalToSuperview().offset(autoWidth(-15.0))
            make.height.equalTo(10.0.autoWidth())
        }
        locationLb.snp.makeConstraints { (make) in
            make.centerY.equalTo(locationPic.snp.centerY)
            make.left.equalTo(locationPic.snp.right).offset(autoWidth(5.0))
            make.right.equalToSuperview().offset(autoWidth(-15.0))
            make.height.equalTo(13.autoWidth())
        }
        pic.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10.0.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(15.0))
            make.width.equalTo(125.0.autoWidth())
            make.height.equalTo(91.0.autoWidth())
            make.bottom.equalToSuperview().offset(-10.0.autoWidth())
        }
        locationPic.snp.makeConstraints { (make) in
            make.bottom.equalTo(pic.snp.bottom)
            make.left.equalTo(nameLb.snp.left)
            make.width.equalTo(11.0.autoWidth())
            make.height.equalTo(13.autoWidth())
        }
        lineView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.height.equalTo(0.5.autoWidth())
        }
    }
}

